package ltd.hxya.novel.admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ltd.hxya.novel.admin.entity.Notice;
import ltd.hxya.novel.admin.service.INoticeService;
import ltd.hxya.novel.common.bean.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hty
 * @since 2022-10-08
 */
@RestController
@RequestMapping("/admin/notice")
public class NoticeController {

    @Autowired
    private INoticeService noticeService;

    //根据条件查询notice
    @GetMapping("/list")
    public Result<Page<Notice>> list(Notice notice){
        Page<Notice> noticePage = noticeService.noticeList(notice);
        return Result.success(noticePage);
    }

    //查询最近三天内的未读通知
    @GetMapping("/notRead")
    public Result<Page<Notice>> list(){
        Page<Notice> noticePage = noticeService.notRead();
        return Result.success(noticePage);
    }

    @DeleteMapping("/deleteNoticeById")
    public Result deleteNoticeById(String[] ids){
        noticeService.deleteNotice(ids);
        return Result.success();
    }

    //清空通知
    @DeleteMapping("/clearNotice")
    public Result clearNotice(){
        noticeService.deleteNotice();
        return Result.success();
    }

    //查询notice的详细信息
    @GetMapping("/detailInfo")
    public Result<String> detailInfo(Notice notice){
        String path = noticeService.detailInfo(notice);
        return Result.success(path);
    }
}
